#pragma once
#include <windows.h>
#include <QtCore>
#include "GCapture.h"
#include "GBmp.hpp"

#define MAX_LOAD 10
class CameraImpl : public GCamera
{
public: 
    CameraImpl(int iCamid, ProcessCallback process, EventCallback evt, void* pContext);
    virtual ~CameraImpl(void);
    virtual bool Init() override;
    virtual const wchar_t* GetDeviceName() override;
    virtual bool Start(){ return m_bRunning = true; }
    virtual bool Stop() { m_bRunning = false; return true; }
    virtual int GetImageWidth();
    virtual int GetImageHeight();
    virtual int GetPixelBytes();
    virtual bool SoftTrigger();
    virtual void ShowImage(bool bShow) {}
    virtual const wchar_t* GetLastError(){ return m_LastError; }

protected:
    QByteArray ReadMainConfig();
    static  DWORD WINAPI GrabImageThread(LPVOID pParam);

private:
    wchar_t m_LastError[256] = { 0 };
    wchar_t m_szDeviceName[512] = { 0 };
    void* m_pCallbakContext = 0;
    bool m_bRunning = false;
    bool m_bInit = false;
    QStringList m_filesList;
    GBmp m_imageLoaded[MAX_LOAD];
    GBmp m_imageProcess;
    HANDLE m_hEvtTrigger;
    HANDLE m_hEvtEnd;
    HANDLE m_hRunThread;
};

